import { z } from "zod";
import { createEnv } from "@t3-oss/env-nextjs";

const booleanString = z.enum(["true", "false"]).transform((val) => val === "true");

/**
 * This is the schema for the environment variables.
 *
 * Please import **this** file and use the `env` variable
 */
export const env = createEnv({
  server: {
    BETTER_AUTH_URL: z.string().url(),
    DATABASE_URL: z.string().url(),
    GOOGLE_CLIENT_ID: z.string().min(1),
    GOOGLE_CLIENT_SECRET: z.string().min(1),
    NODE_ENV: z.enum(["development", "production", "test"]),
    BETTER_AUTH_SECRET: z.string().min(1),
    OPENPANEL_SECRET_KEY: z.string().optional(),
    SMTP_HOST: z.string().optional(),
    SMTP_PORT: z.coerce.number().positive().optional(),
    SMTP_USER: z.string().optional(),
    SMTP_PASS: z.string().optional(),
    SMTP_FROM: z.string().optional(),
    //issue fixed in zod 4. See https://github.com/colinhacks/zod/issues/3906
    SMTP_SECURE: booleanString.default("false"),

    STRIPE_SECRET_KEY: z.string().optional(),
    STRIPE_WEBHOOK_SECRET: z.string().optional(),

    // RevenueCat configuration
    REVENUECAT_SECRET_KEY: z.string().optional(),
    REVENUECAT_WEBHOOK_SECRET: z.string().optional(),
  },
  /**
   * If you add `client` environment variables, you need to add them to
   * `experimental__runtimeEnv` as well.
   */
  client: {
    NEXT_PUBLIC_OPENPANEL_CLIENT_ID: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: z.string().optional(),
    NEXT_PUBLIC_APP_URL: z.string().url(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_EU: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_EU: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_US: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_US: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_LATAM: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_LATAM: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_BR: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_BR: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_RU: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_RU: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_CN: z.string().optional(),
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_CN: z.string().optional(),
    NEXT_PUBLIC_SHOW_ADS: booleanString.optional(),
    NEXT_PUBLIC_AD_CLIENT: z.string().optional(),
    NEXT_PUBLIC_VERTICAL_LEFT_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_VERTICAL_RIGHT_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_EQUIPMENT_SELECTION_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_EXERCISE_SELECTION_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_MUSCLE_SELECTION_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_WORKOUT_SESSION_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_WORKOUT_SESSION_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_STEPPER_STEP_1_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_STEPPER_STEP_2_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_STEPPER_STEP_3_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_PROGRAMS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_PROGRAMS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_TOOLS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_TOOLS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_CALCULATOR_HUB_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_CALCULATOR_HUB_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_PROGRAM_DETAILS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_PROGRAM_DETAILS_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_PROFILE_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_IN_ARTICLE_BMI_1_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_IN_ARTICLE_BMI_2_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_BMI_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_BMI_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_HEART_ZONES_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_HEART_ZONES_BANNER_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_1: z.string().optional(),
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_2: z.string().optional(),
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_3: z.string().optional(),
    NEXT_PUBLIC_TOP_MIFFLIN_ST_JEOR_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_OXFORD_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_OXFORD_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_HARRIS_BENEDICT_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_KATCH_MCARDLE_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_CUNNINGHAM_CALCULATOR_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_TOP_CALORIE_CALCULATOR_COMPARISON_AD_SLOT: z.string().optional(),
    NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_COMPARISON_AD_SLOT: z.string().optional(),
    // Ezoic configuration
    NEXT_PUBLIC_AD_PROVIDER: z.enum(["adsense", "ezoic"]).optional().default("adsense"),
    NEXT_PUBLIC_EZOIC_VERTICAL_LEFT_PLACEMENT_ID: z.string().optional(),
    NEXT_PUBLIC_EZOIC_VERTICAL_RIGHT_PLACEMENT_ID: z.string().optional(),
    NEXT_PUBLIC_EZOIC_EQUIPMENT_SELECTION_PLACEMENT_ID: z.string().optional(),
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_1_PLACEMENT_ID: z.string().optional(),
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_2_PLACEMENT_ID: z.string().optional(),
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_3_PLACEMENT_ID: z.string().optional(),
    // GA4
    NEXT_PUBLIC_GA4_MEASUREMENT_ID: z.string().optional(),
  },

  experimental__runtimeEnv: {
    NEXT_PUBLIC_OPENPANEL_CLIENT_ID: process.env.NEXT_PUBLIC_OPENPANEL_CLIENT_ID,
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,
    NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_EU: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_EU,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_EU: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_EU,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_US: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_US,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_US: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_US,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_LATAM: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_LATAM,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_LATAM: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_LATAM,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_BR: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_BR,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_BR: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_BR,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_RU: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_RU,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_RU: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_RU,
    NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_CN: process.env.NEXT_PUBLIC_STRIPE_PRICE_MONTHLY_CN,
    NEXT_PUBLIC_STRIPE_PRICE_YEARLY_CN: process.env.NEXT_PUBLIC_STRIPE_PRICE_YEARLY_CN,
    NEXT_PUBLIC_SHOW_ADS: process.env.NEXT_PUBLIC_SHOW_ADS,
    NEXT_PUBLIC_AD_CLIENT: process.env.NEXT_PUBLIC_AD_CLIENT,
    NEXT_PUBLIC_VERTICAL_LEFT_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_VERTICAL_LEFT_BANNER_AD_SLOT,
    NEXT_PUBLIC_VERTICAL_RIGHT_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_VERTICAL_RIGHT_BANNER_AD_SLOT,
    NEXT_PUBLIC_EQUIPMENT_SELECTION_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_EQUIPMENT_SELECTION_BANNER_AD_SLOT,
    NEXT_PUBLIC_EXERCISE_SELECTION_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_EXERCISE_SELECTION_BANNER_AD_SLOT,
    NEXT_PUBLIC_MUSCLE_SELECTION_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_MUSCLE_SELECTION_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_WORKOUT_SESSION_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_WORKOUT_SESSION_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_WORKOUT_SESSION_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_WORKOUT_SESSION_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_STEPPER_STEP_1_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_STEPPER_STEP_1_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_STEPPER_STEP_2_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_STEPPER_STEP_2_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_STEPPER_STEP_3_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_STEPPER_STEP_3_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_PROGRAMS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_PROGRAMS_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_PROGRAMS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_PROGRAMS_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_TOOLS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_TOOLS_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_TOOLS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_TOOLS_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_CALCULATOR_HUB_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_CALCULATOR_HUB_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_CALCULATOR_HUB_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_CALCULATOR_HUB_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_PROGRAM_DETAILS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_PROGRAM_DETAILS_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_PROGRAM_DETAILS_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_PROGRAM_DETAILS_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_PROFILE_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_PROFILE_BANNER_AD_SLOT,
    NEXT_PUBLIC_IN_ARTICLE_BMI_1_AD_SLOT: process.env.NEXT_PUBLIC_IN_ARTICLE_BMI_1_AD_SLOT,
    NEXT_PUBLIC_IN_ARTICLE_BMI_2_AD_SLOT: process.env.NEXT_PUBLIC_IN_ARTICLE_BMI_2_AD_SLOT,
    NEXT_PUBLIC_TOP_BMI_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_BMI_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_BMI_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_BMI_BANNER_AD_SLOT,
    NEXT_PUBLIC_TOP_HEART_ZONES_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_TOP_HEART_ZONES_BANNER_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_HEART_ZONES_BANNER_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_HEART_ZONES_BANNER_AD_SLOT,
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_1: process.env.NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_1,
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_2: process.env.NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_2,
    NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_3: process.env.NEXT_PUBLIC_IN_ARTICLE_HEART_ZONES_AD_SLOT_3,
    NEXT_PUBLIC_TOP_MIFFLIN_ST_JEOR_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_TOP_MIFFLIN_ST_JEOR_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_TOP_OXFORD_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_TOP_OXFORD_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_OXFORD_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_OXFORD_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_TOP_HARRIS_BENEDICT_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_TOP_HARRIS_BENEDICT_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_TOP_KATCH_MCARDLE_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_TOP_KATCH_MCARDLE_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_TOP_CUNNINGHAM_CALCULATOR_AD_SLOT: process.env.NEXT_PUBLIC_TOP_CUNNINGHAM_CALCULATOR_AD_SLOT,
    NEXT_PUBLIC_TOP_CALORIE_CALCULATOR_COMPARISON_AD_SLOT: process.env.NEXT_PUBLIC_TOP_CALORIE_CALCULATOR_COMPARISON_AD_SLOT,
    NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_COMPARISON_AD_SLOT: process.env.NEXT_PUBLIC_BOTTOM_CALORIE_CALCULATOR_COMPARISON_AD_SLOT,
    NEXT_PUBLIC_AD_PROVIDER: process.env.NEXT_PUBLIC_AD_PROVIDER,
    NEXT_PUBLIC_EZOIC_VERTICAL_LEFT_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_VERTICAL_LEFT_PLACEMENT_ID,
    NEXT_PUBLIC_EZOIC_VERTICAL_RIGHT_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_VERTICAL_RIGHT_PLACEMENT_ID,
    NEXT_PUBLIC_EZOIC_EQUIPMENT_SELECTION_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_EQUIPMENT_SELECTION_PLACEMENT_ID,
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_1_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_1_PLACEMENT_ID,
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_2_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_2_PLACEMENT_ID,
    NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_3_PLACEMENT_ID: process.env.NEXT_PUBLIC_EZOIC_TOP_STEPPER_STEP_3_PLACEMENT_ID,
    NEXT_PUBLIC_GA4_MEASUREMENT_ID: process.env.NEXT_PUBLIC_GA4_MEASUREMENT_ID,
  },
});
